package com.zdlog.ler.controller;


import com.zdlog.ler.Resp.object.ResponeMessage;
import com.zdlog.ler.Resp.util.ResponeMessageUtil;
import com.zdlog.ler.entity.LerUser;
import com.zdlog.ler.service.LerUserService;
import com.zdlog.ler.util.TextUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.cache.CacheProperties;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Set;

@RestController
@RequestMapping("/lerUser")
@Slf4j
public class LerUserController {

    @Autowired
    private LerUserService lerUserService;

    /**
     * 注册
     * @param lerUser
     * @return
     */
    @PostMapping("/register")
    public ResponeMessage register(@RequestBody LerUser lerUser) {
        return lerUserService.register(lerUser);
    }

    /**
     * 登录
     * @param lerUser
     * @param response
     * @return
     */
    @PostMapping("/login")
    public ResponeMessage login(@RequestBody LerUser lerUser, HttpServletResponse response) {
        return   lerUserService.login(response,lerUser);
    }

    /**
     * 发送Emil注册邮件
     * @param lerUser
     * @return
     */
    @PostMapping("/sendMail")
    public ResponeMessage sendEmail(@RequestBody LerUser lerUser) {
        return lerUserService.sendEmail(lerUser);
    }





    /**
     * 登出
     * @param request
     * @param response
     * @return
     */
    @PostMapping("/logout")
    public ResponeMessage logout(HttpServletRequest request, HttpServletResponse response) {
        return lerUserService.logout(request, response);
    }

}
